package leetcode.map;

import java.util.Arrays;
import java.util.HashMap;

public class Lc506 {

    public String[] findRelativeRanks(int[] score) {

        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < score.length; i++) {
            map.put(score[i], i);
        }
        Arrays.sort(score);
        String[] ans = new String[score.length];
        for (int i = 0; i < score.length; i++) {
            int idx = map.get(score[i]);
            if (i == score.length - 1) {
                ans[idx] = "Gold Medal";
            } else if (i == score.length - 2) {
                ans[idx] = "Silver Medal";
            } else if (i == score.length - 3) {
                ans[idx] = "Bronze Medal";
            } else ans[idx] = String.valueOf(score.length - i);
        }
        return ans;
    }


}
